#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/fcntl.h>

#include "rand.h"


#define BUF_LEN 12

int main(int argc, char **argv)
{
/*	int i;
	for(i=0;i<32;i++)
	{
		char buf[12]={0};
		get_rand_str(buf, 12);
		printf("%s\n", buf);
	}*/

	int fd = open("./indata.bl", O_RDWR|O_CREAT|O_TRUNC, 00777);
	if(fd==-1)
		printf("open file error!\n");

	char buf[BUF_LEN];


	int m;
	for(m=0;m<10000;m++)
	{
		memset((void*)buf, 0x00, BUF_LEN*sizeof(char));
		int i = get_rand_num()%13 + 4;

		char *p = get_rand_str(buf, i);
		int ret= write(fd, p, strlen(p));
		if(ret==-1)
		{
			printf("write error!\n");
			break;
		}
		ret = write(fd, "\n", sizeof(char));		
		if(ret==-1)
		{
			printf("write error!\n");
			break;
		}
	}

	close(fd);	
	return 0;
};
